<template>
  <PageWrapper>
    <template #headerContent> <WorkbenchHeader /> </template>
    <div class="lg:flex">
      <div class="lg:w-7/10 w-full !mr-4 enter-y">
        <ProjectCard
          :loading="loading"
          class="enter-y"
          :title="'所在班级'"
          :list="state.classList"
        />
        <ProjectCard
          :loading="loading"
          class="enter-y"
          :title="'指导社团'"
          :list="studentGroups"
          style="margin-top: 16px"
        />
        <DynamicInfo :loading="loading" class="!my-4 enter-y" />
      </div>
      <div class="lg:w-3/10 w-full enter-y">
        <QuickNav :loading="loading" class="enter-y" @click="openModal1" />

        <Card class="!my-4 enter-y" :loading="loading">
          <img class="xl:h-50 h-30 mx-auto" src="../../assets/svg/illustration.svg" />
        </Card>

        <SaleRadar :loading="loading" class="enter-y" />
      </div>
    </div>
    {{ state.classList }}
    <Modal @register="register1" :title="'请选择班级'" :options="state.classList" />
  </PageWrapper>
</template>

<script lang="ts" setup>
  import { ref, toRaw, reactive } from 'vue';
  import { Card } from 'ant-design-vue';
  import { PageWrapper } from '/@/components/Page';
  import WorkbenchHeader from './components/WorkbenchHeader.vue';
  import ProjectCard from './components/ProjectCard.vue';
  import QuickNav from './components/QuickNav.vue';
  import DynamicInfo from './components/DynamicInfo.vue';
  import { useTeacherStore } from '/@/store/modules/teacher';
  import { useModal } from '/@/components/Modal';
  import Modal from './components/Modal.vue';

  const [register1, { openModal: openModal1 }] = useModal();

  let state = reactive<any>({
    classList: [],
  });
  const loading = ref(false);
  // 获取表格数据
  async function getClassList() {
    loading.value = true;
    try {
      await useTeacherStore()
        .getClassListAction(
          toRaw({
            mode: 'none', //不要默认的错误提示
          }),
        )
        .then((resolve) => {
          state.classList = resolve.map((item) => {
            console.log(item);
            return { value: item.id, label: item.name, ...item };
          });
          console.log(state.classList);

          loading.value = false;
        });
    } catch (error) {
      console.log(error);
      loading.value = false;
    }
  }
  getClassList();
</script>
